<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Grid布局</title>
    <style>
        .parent {
            width: 400px;
            height: 400px;
            margin: 50px auto;
            background-color: rgb(148, 235, 238);

            display: grid;
            grid-template-rows: repeat(3, 1fr);
            grid-template-columns: repeat(3, 1fr);

            /* 间距 */
            grid-row-gap: 15px;
            grid-column-gap: 15px;

            /* 简写 */
            row-gap: 10px;
            column-gap: 10px;

            /* 再简写 */
            /* gap: 行间距 列间距; */
            /* gap: 5px 5px; */
            gap: 5px;
        }

        .child {
            background-color: red;

            /* 背景裁切：只看content的背景，不包括padding、border */
            /* background-clip: content-box; */

            /* 背景裁切：content、padding、border一起的背景 */
            /* background-clip: border-box; */

            /* 间距 */
            /* 以下两种都有问题：多余的边界、中间的间距是累加的 */
            /* margin: 15px; */
            /* padding: 15px; */
        }
    </style>
</head>

<body>

    <div class="parent">
        <div class="child item01">1</div>
        <div class="child item02">2</div>
        <div class="child item03">3</div>
        <div class="child item04">4</div>
        <div class="child item05">5</div>
        <div class="child item06">6</div>
        <div class="child item07">7</div>
        <div class="child item08">8</div>
        <div class="child item09">9</div>
    </div>

</body>

</html>